/*
 * @Author: wangding
 * @Date: 2020-09-07 09:55:28
 * @LastEditTime: 2020-10-20 12:08:37
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \wifiGuidance\js\wifiGuidance.js
 */
$(function() {
    var localLan = localStorage.getItem('lan');
    initDom(returnLanCode(localLan || 'zh_CN'), localLan || 'zh_CN') //初始化  默认为中文
    var flag = 1
    $(".lanSelect").click(function() {
            if (flag % 2 == 1) {
                $(".dropdown-menu").show();
            } else {
                $(".dropdown-menu").hide();
            }
            flag++
        })
        //实现tab栏切换
    $('.sub-tabs-box').click(function(e) {
        var index = $(this).attr('data-index')
        $(this).addClass('active').siblings('div').removeClass('active')
        $($('.content-sub-box')[index - 1]).show().siblings('div').hide()

    })
    $('.dropdown-menu li').click(function() {
        var lan = $(this).children('a').attr('data-language')
        var lanData = returnLanCode(lan)
        initDom(lanData, lan)
        $('.dropdown-menu').hide()
        flag++
        localStorage.setItem('lan', lan);
    })
});

function initDom(data, lan) {
    //不同语言不同的图片
    $('.wifi1').attr('src', `./images/${lan}/wifi1.png`)
    $('.wifi2').attr('src', `./images/${lan}/wifi2.png`)
    $('.wifi3').attr('src', `./images/${lan}/wifi3.png`)
    $('.wifi4').attr('src', `./images/${lan}/wifi4.png`)
    $('.wifi5').attr('src', `./images/${lan}/wifi5.png`)
    $('.wifi6').attr('src', `./images/${lan}/wifi6.png`)
    $('.wifi7').attr('src', `./images/${lan}/wifi7.png`)
    $('.wifi8').attr('src', `./images/${lan}/wifi8.png`)
    $('.wifi9').attr('src', `./images/${lan}/wifi9.png`)
    $('.wifi10').attr('src', `./images/${lan}/wifi10.png`)

    //为不同语言赋值
    $('.guidance-Wifi-h5').text(data['guidance-Wifi-h5'])
    $('.guidance-Wifi-p1').text(data['guidance-Wifi-p1'])
    $('.guidance-Wifi-p2').text(data['guidance-Wifi-p2'])
    $('.guidance-Wifi-p3').text(data['guidance-Wifi-p3'])
    $('.guidance-Wifi-p4').text(data['guidance-Wifi-p4'])
    $('.guidance-Wifi-p5').text(data['guidance-Wifi-p5'])
    $('.guidance-Wifi-p6').text(data['guidance-Wifi-p6'])
    $('.guidance-Wifi-p7').text(data['guidance-Wifi-p7'])
    $('.guidance-Wifi-p8').text(data['guidance-Wifi-p8'])
    $('.guidance-Wifi-p9').text(data['guidance-Wifi-p9'])
    $('.guidance-Wifi-p10').text(data['guidance-Wifi-p10'])
    $('.guidance-Wifi-p11').text(data['guidance-Wifi-p11'])
    $('.guidance-Wifi-p12').text(data['guidance-Wifi-p12'])

    $('.guidance-local-h5').text(data['guidance-local-h5'])
    $('.guidance-local-h5-2').text(data['guidance-local-h5-2'])

    $('.guidance-local-p1').text(data['guidance-local-p1'])
    $('.guidance-local-p2').text(data['guidance-local-p2'])
    $('.guidance-local-p3').text(data['guidance-local-p3'])
    $('.guidance-local-p4').text(data['guidance-local-p4'])
    $('.guidance-local-p5').text(data['guidance-local-p5'])
    $('.guidance-local-p6').text(data['guidance-local-p6'])
    $('.guidance-local-p7').text(data['guidance-local-p7'])
    $('.guidance-local-p8').text(data['guidance-local-p8'])

    $('.guidance-local-p9').text(data['guidance-local-p9'])
    $('.guidance-local-p10').text(data['guidance-local-p10'])

    $('.guidance-pocket-h5').text(data['guidance-pocket-h5'])
    $('.guidance-pocket-pTitle').text(data['guidance-pocket-pTitle'])
    $('.guidance-pocket-p1').text(data['guidance-pocket-p1'])
    $('.guidance-pocket-p2').text(data['guidance-pocket-p2'])
    $('.guidance-pocket-p3').text(data['guidance-pocket-p3'])
    $('.guidance-pocket-p4').text(data['guidance-pocket-p4'])
    $('.guidance-pocket-p5').text(data['guidance-pocket-p5'])

    $('.guidance-quick-h5').text(data['guidance-quick-h5'])
    $('.guidance-quick-p1').text(data['guidance-quick-p1'])
    $('.guidance-quick-p2').text(data['guidance-quick-p2'])
    $('.guidance-quick-p3').text(data['guidance-quick-p3'])
    $('.guidance-quick-p4').text(data['guidance-quick-p4'])
    $('.guidance-quick-p5').text(data['guidance-quick-p5'])
    $('.guidance-quick-p6').text(data['guidance-quick-p6'])
    $('.guidance-quick-p7').text(data['guidance-quick-p7'])
    $('.guidance-quick-p8').text(data['guidance-quick-p8'])
        //为了插入<br>元素
    $('.title1').text('')
    $('.title2').text('')
    $('.title3').text('')
    $('.title4').text('')
    $('.selectLan').text(data['selectLan'])
    $('.title1').append(data['title1'])
    $('.title2').append(data['title2'])
    $('.title3').append(data['title3'])
    $('.title4').append(data['title4'])

}